(function(){
	
	function TuYou(){
	
		this.randomNumber = new Date().getTime(); // 随机数
		this.version = "TuYou2.0"; // 当前TuYou的版本
		this.SUCCESS = 'success'; //成功字符串 标记用
		this.FAILTURE = 'failture'; //失败字符串 标记用
		this.YES = 1; //成功 标记用
		this.NO = 0; //失败 标记用
	};
	
	/**
	 * cookie操作（获取，设置，删除）
	 */
	TuYou.prototype.Cookie = {
		get : function(name){
			
			var start = document.cookie.indexOf(name + "=");
			if (start == -1) {
				
				return null;
			}
			start = start + name.length + 1;
			
			var end = document.cookie.indexOf(";", start);
			if (end == -1) {
				
				end = document.cookie.length;
			}
			return document.cookie.substring(start, end);
		},
		set : function(name, value, expires, domain, secure){
			
			//不要忘了在对应getCookie函数里面加上decodeURI方法
			var str = name + "=" + encodeURI(value);
			if(expires){
				str += "; expires=" + expires.toGMTString();
			}
			if (domain) {
				str += "; domain=" + domain;
			}
			if (secure) {
				str += "; secure";
			}
			document.cookie = str;
		},
		remove : function(name){
			
			var expires = new Date();
			expires.setTime(expires.getTime() - 1);//将expires设为一个过去的日期，浏览器会自动删除它
			var cval = tuyou.Cookie.get(name);
			document.cookie = name + "=" + cval + "; expires=" + expires.toGMTString();
		}
	};
	
	/**
	 * 文件上传的一些方法(调用后台的jqueryFileUpload)
	 */
	TuYou.prototype.FileUpload = {
		
		/**
		 * 保存裁剪的图片
		 */
		imgs : {},
		/**
		 * 直接上传图片 不裁剪
		 */
		directUpload : function(param, fileQueue){
			
			var loading = tuyou.loading('正在调起中...');
			var $file = $('<input type="file" name="' + param.name + '" accept="image/*" style="display:none;">');
			$file.trigger('click');
			$file.change(function(){
				
				loading.modal('hide');
				tuyou.img.readFromFile($file, function(dataUrl){
					
//					var formData = new FormData();
//					formData.append('picture', $file[0].files[0], dataUrl.split(',')[0].match(/:(.*?);/)[1]);
					
					if(!param.multi){
						
						//如果不是多文件上传，则删除之后上传的
						fileQueue.empty();
					}
					$file.appendTo(fileQueue);
					var $img = $('<img src="' + dataUrl + '" style="width:100px;"/>'); //创建显示图片，只固定宽度，防止拉升失真
					$img.appendTo(fileQueue);
				});
			});
		},
		
		/**
		 * 图片上传，要裁剪
		 * @param width 图片的长
		 * @param height 图片的宽
		 * @param callback(json) 上传成功的回调函数
		 * 			json.dataUrl 剪切后的图片
		 * 			json.status 上传是否成功
		 * 			json.info.fileName 上传图片的路径、类型、原名、新名
		 * 			json.info.path 图片的路径
		 * 			json.info.id 图片的id
		 */
		cutUpload : function(param, fileQueue){
			
			var loading = tuyou.loading('正在调起中...');
			var $file = $('<input type="file" name="' + param.name + '" accept="image/*" style="display:none;">');
			$file.trigger('click');
			$file.change(function(){

				loading.modal('hide');
				tuyou.img.readFromFile($file, function(dataUrl){
					
					tuyou.img.showClipWindow(dataUrl, param.width, param.height, function(scale){
						
						var blob = tuyou.convert.dataURLtoBlob(scale);
						if(!param.multi){
							
							//如果不是多文件上传，则删除之后上传的
							fileQueue.empty();
							tuyou.FileUpload.imgs[param.name] = [];
						}
						$file.appendTo(fileQueue);
						if(tuyou.isNull(tuyou.FileUpload.imgs[param.name])){
							
							tuyou.FileUpload.imgs[param.name] = [];
						}
						tuyou.FileUpload.imgs[param.name].push(blob);
						var $img = $('<img src="' + scale + '" style="width:100px;"/>'); //创建显示图片，只固定宽度，防止拉升失真
						$img.appendTo(fileQueue);
					});
				});
			});
		}
	};
	
	/**
	 * 图像类操作
	 */
	TuYou.prototype.img = {
			
		/**
		 * 读取img
		 * @param $img 要去读的img标签
		 * @param callback(dataUrl) 通过回调函数返回url
		 */
		readFromImg : function($img, callback){
			
			var loading = tuyou.loading("加载中...");
			var canvas = document.createElement('canvas');
	        var ctx = canvas.getContext('2d');
	        canvas.height = $img[0].attr('height');
	        canvas.width = $img[0].attr('width');
	        ctx.drawImage($img[0], 0, 0);
	        var dataURL = canvas.toDataURL(outputFormat);
	        loading.modal('hide');
	        callback(dataURL);
		},
		
		/**
		 * 读取img从一个网络url连接地址
		 * @param url 连接地址
		 * @param callback(dataUrl) 通过回调函数返回url
		 */
		readFromUrl : function(url, callback){
			
			var loading = tuyou.loading("加载中...");
			var image = new Image();
			image.src = url;
			image.onload = function(){
				
				var canvas = document.createElement('canvas');
				var ctx = canvas.getContext('2d');
				canvas.height = image.height;
				canvas.width = image.width;
				ctx.drawImage(image, 0, 0);
				var dataURL = canvas.toDataURL(outputFormat);
				loading.modal('hide');
				callback(dataURL);
			};
		},
		
		/**
		 * 读取img从一个网络url连接地址
		 * @param $file 连接地址
		 * @param callback(dataUrl) 通过回调函数返回url
		 */
		readFromFile : function($file, callback){
			
			var loading = tuyou.loading("加载中...");
			//检验是否为图像文件  
		    var file = $file[0].files[0];  
		    if(!/image\/\w+/.test(file.type)){  
		        alert("看清楚，这个需要图片！");  
		        return false;  
		    }  
		    var reader = new FileReader();  
		    //将文件以Data URL形式读入页面  
		    reader.readAsDataURL(file);  
		    reader.onload=function(e){  
		    	
		    	loading.modal('hide');
		        callback(this.result);
		    };
		},
		
		/**
		 * 图片缩放
		 * @param dataUrl 图片的dataUrl
		 * @param width 图片后的宽度
		 * @param height 图片后的高度
		 * @returns 返回缩放后的dataUrl
		 */
		scale : function(dataUrl, width, height){
			
			var loading = tuyou.loading("处理中...");
			var mime_type = dataUrl.split(';')[0].substring(5);
	        var cvs = document.createElement('canvas');
	        //naturalWidth真实图片的宽度
	        cvs.width = width;
	        cvs.height = height;
	        var image = new Image();
			image.src = dataUrl;
			cvs.getContext("2d").drawImage(image, 0, 0, width, height);
	        var newImageData = cvs.toDataURL(mime_type);
	        loading.modal('hide');
	        return newImageData;
		},
		
		/**
		 * 图片裁剪
		 * @param dataUrl 图片的dataUrl
		 * @param x 图片裁剪的起始横坐标
		 * @param y 图片裁剪的起始纵坐标
		 * @param width 裁剪区域的宽度
		 * @param height 裁剪区域的高度
		 * @returns 返回处理后的dataUrl
		 */
		clip : function(dataUrl, x, y, width, height){
			
			var loading = tuyou.loading("裁剪中...");
			var mime_type = dataUrl.split(';')[0].substring(5);
			var cvs = document.createElement('canvas');
			if(tuyou.isNull(cvs)){
				
				tuyou.alert('不支持绘图');
			}
			//naturalWidth真实图片的宽度
			cvs.width = width;
			cvs.height = height;
			var image = new Image();
			image.src = dataUrl;
			cvs.getContext("2d").drawImage(image, -x, -y);
			var newImageData = cvs.toDataURL(mime_type);
			loading.modal('hide');
			return newImageData;
		},
		
		/**
		 * 显示图片裁剪窗体
		 * @param dataUrl 原始图片
		 * @param wdith 要裁剪的长
		 * @param height 要裁剪的宽
		 * @param callback(dataUrl) 回调函数，参数为处理后的dataUrl
		 */
		showClipWindow : function(dataUrl, width, height, callback){
			
			var $img = $('<div style="width:570px; height:500px;">'
					+ '<img src="'+dataUrl+'" id="cutFileId"/>'
					+ '</div>');
			var scale = null;
			$img.find('img').cropper({  //把div变成一个剪切框
				aspectRatio: width / height, //裁剪的长宽比
				crop: function (data) {
					
					scale = data;
				}
			});
			$img.on({'build.cropper' : function(data){ //记录剪切的大小，scale={x, y, width, height}
				
				scale = data;
			}});
			
			var dialog = bootbox.dialog({//把剪切框显示弹出框中
	            title: '图片剪切',
	            message: function(dialog) {
	            	
	                return $img;  //把剪切框显示弹出框中
	            },
	            buttons: [{
	                label: '确定',
	                callback: function() {
	                	
	                	dialog.modal('hide'); //关闭剪切窗口
	                	var sourceDataUrl = $img.find('img')[0].src;
	                	var clipDataUrl = tuyou.img.clip(sourceDataUrl, scale.x, scale.y, scale.width, scale.height); //剪切
	                	var scaleDataUrl = tuyou.img.scale(clipDataUrl, width, height);
	                	callback(clipDataUrl);
	                }
	            }]
	        });
		},
		
		/**
		 * 显示图片裁剪窗体，并且把剪切后的图片显示在指定的img标签上
		 * @param dataUrl 原始图片
		 * @param s 要裁剪的长宽比
		 * @param $img 剪切好后要显示在的img标签
		 */
		clipToImgShow : function(dataUrl, s, $img){
			
			tuyou.img.showClipWindow(dataUrl, s, function(newDataUrl){
				
				$img.attr('src', '');//先制空，否则不刷新
				$img.attr('src', newDataUrl); //把剪切后的DataUrl显示在指定的img标签上
			});
		},
		
		/**
		 * 图片清晰度调整
		 * @param dataUrl
		 * @param quality 图片调整度（1为不调整）
		 * @returns 返回处理后的dataUrl
		 */
		quality : function(dataUrl, quality){
			
			var loading = tuyou.loading("处理中...");
			var mime_type = data.split(';')[0].substring(5);
			var cvs = document.createElement('canvas');
			//naturalWidth真实图片的宽度
			cvs.width = dataUrl.naturalWidth;
			cvs.height = dataUrl.naturalHeight;
			var ctx = cvs.getContext("2d");
			var image = new Image();
			image.src = dataUrl;
			ctx.drawImage(image, 0, 0);
			var newImageData = cvs.toDataURL(mime_type, quality); //指定清晰度
			loading.modal('hide');
			return newImageData;
		}
	};
	
	/**
	 * 类型转换类
	 */
	TuYou.prototype.convert = {
			
		dataURLtoBlob : function (dataurl) {
			
			var arr = dataurl.split(','), mime = arr[0].match(/:(.*?);/)[1],
	        bstr = atob(arr[1]), n = bstr.length, u8arr = new Uint8Array(n);
		    while(n--){
		        u8arr[n] = bstr.charCodeAt(n);
		    }
		    return new Blob([u8arr], {type:mime});
		}
	};
	
	/* 
	 * 加密解密 
	 * */  
	var base64EncodeChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";  
	var base64DecodeChars = new Array(-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,  
	        -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,  
	        -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1,  
	        63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1, -1,  
	        0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,  
	        20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, -1, 26, 27, 28, 29, 30, 31,  
	        32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49,  
	        50, 51, -1, -1, -1, -1, -1);  
	TuYou.prototype.base64encode = function (str) {  
	    var out, i, len;  
	    var c1, c2, c3;  
	    len = str.length;  
	    i = 0;  
	    out = "";  
	    while (i < len) {  
	        c1 = str.charCodeAt(i++) & 0xff;  
	        if (i == len) {  
	            out += base64EncodeChars.charAt(c1 >> 2);  
	            out += base64EncodeChars.charAt((c1 & 0x3) << 4);  
	            out += "==";  
	            break;  
	        }  
	        c2 = str.charCodeAt(i++);  
	        if (i == len) {  
	            out += base64EncodeChars.charAt(c1 >> 2);  
	            out += base64EncodeChars.charAt(((c1 & 0x3) << 4)  
	                    | ((c2 & 0xF0) >> 4));  
	            out += base64EncodeChars.charAt((c2 & 0xF) << 2);  
	            out += "=";  
	            break;  
	        }  
	        c3 = str.charCodeAt(i++);  
	        out += base64EncodeChars.charAt(c1 >> 2);  
	        out += base64EncodeChars.charAt(((c1 & 0x3) << 4) | ((c2 & 0xF0) >> 4));  
	        out += base64EncodeChars.charAt(((c2 & 0xF) << 2) | ((c3 & 0xC0) >> 6));  
	        out += base64EncodeChars.charAt(c3 & 0x3F);  
	    }  
	    return out;  
	};
	
	TuYou.prototype.base64decode = function (str) {  
	    var c1, c2, c3, c4;  
	    var i, len, out;  
	    len = str.length;  
	    i = 0;  
	    out = "";  
	    while (i < len) {  
	        /* c1 */  
	        do {  
	            c1 = base64DecodeChars[str.charCodeAt(i++) & 0xff];  
	        } while (i < len && c1 == -1);  
	        if (c1 == -1)  
	            break;  
	        /* c2 */  
	        do {  
	            c2 = base64DecodeChars[str.charCodeAt(i++) & 0xff];  
	        } while (i < len && c2 == -1);  
	        if (c2 == -1)  
	            break;  
	        out += String.fromCharCode((c1 << 2) | ((c2 & 0x30) >> 4));  
	        /* c3 */  
	        do {  
	            c3 = str.charCodeAt(i++) & 0xff;  
	            if (c3 == 61)  
	                return out;  
	            c3 = base64DecodeChars[c3];  
	        } while (i < len && c3 == -1);  
	        if (c3 == -1)  
	            break;  
	        out += String.fromCharCode(((c2 & 0XF) << 4) | ((c3 & 0x3C) >> 2));  
	        /* c4 */  
	        do {  
	            c4 = str.charCodeAt(i++) & 0xff;  
	            if (c4 == 61)  
	                return out;  
	            c4 = base64DecodeChars[c4];  
	        } while (i < len && c4 == -1);  
	        if (c4 == -1)  
	            break;  
	        out += String.fromCharCode(((c3 & 0x03) << 6) | c4);  
	    }  
	    return out;  
	};
	
	TuYou.prototype.utf16to8 = function (str) {  
	    var out, i, len, c;  
	    out = "";  
	    len = str.length;  
	    for (i = 0; i < len; i++) {  
	        c = str.charCodeAt(i);  
	        if ((c >= 0x0001) && (c <= 0x007F)) {  
	            out += str.charAt(i);  
	        } else if (c > 0x07FF) {  
	            out += String.fromCharCode(0xE0 | ((c >> 12) & 0x0F));  
	            out += String.fromCharCode(0x80 | ((c >> 6) & 0x3F));  
	            out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F));  
	        } else {  
	            out += String.fromCharCode(0xC0 | ((c >> 6) & 0x1F));  
	            out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F));  
	        }  
	    }  
	    return out;  
	};
	
	TuYou.prototype.utf8to16 = function (str) {  
	    var out, i, len, c;  
	    var char2, char3;  
	    out = "";  
	    len = str.length;  
	    i = 0;  
	    while (i < len) {  
	        c = str.charCodeAt(i++);  
	        switch (c >> 4) {  
	        case 0:  
	        case 1:  
	        case 2:  
	        case 3:  
	        case 4:  
	        case 5:  
	        case 6:  
	        case 7:  
	            // 0xxxxxxx  
	            out += str.charAt(i - 1);  
	            break;  
	        case 12:  
	        case 13:  
	            // 110x xxxx 10xx xxxx  
	            char2 = str.charCodeAt(i++);  
	            out += String.fromCharCode(((c & 0x1F) << 6) | (char2 & 0x3F));  
	            break;  
	        case 14:  
	            // 1110 xxxx 10xx xxxx 10xx xxxx  
	            char2 = str.charCodeAt(i++);  
	            char3 = str.charCodeAt(i++);  
	            out += String.fromCharCode(((c & 0x0F) << 12)  
	                    | ((char2 & 0x3F) << 6) | ((char3 & 0x3F) << 0));  
	            break;  
	        }  
	    }  
	    return out;  
	};
	
	/**
	 * 多级联动
	 * @param ids 需要联动的select, 按顺序组成一个数组
	 * @param url 请求的地址,不带参数的
	 * @param valueField 
	 * @param nameField
	 * @param callbacks 回调函数
	 */
	TuYou.prototype.multiGradeCascade = function (ids, url, valueField, nameField, callbacks){
		
		var params = {};
		for(var i = 0; ids && i < ids.length; i++){
			
			var id = ids[i];
			$("#" + id).change(function(){
				
				var value = $(this).val();
				var id = $(this).attr('id');
				params[valueField] = value;
				$.post(
						url,
						params,
						function(json){
							
							//先检测是否提供了回调函数，提供了就执行回调函数
							for(var k = 0; callbacks &&  k < ids.length; k++){
								
								if(id == ids[k]){
									
									var callback = callbacks[k];
									if(callback){
										
										callback(json);
										return;
									}
								}
							}
							
							//先检测是否提供了回调函数，提供了就执行回调函数
							for(var k = 0; callbacks &&  k < ids.length; k++){
								
								if(id == ids[k]){
									
									//执行默认动作
									var $next = $("#" + ids[k+1]);
									$next.children().remove();
									for(var j = 0; json && j < json.length; j++){
										
										$next.append('<option value="' + json[j][valueField] + '">' + json[j][nameField] + '</option>');
									}
									$next.trigger('change');
								}
							}
							
						}, 'json');
			});
		}
	};
	
	/**
	 * 分页查询
	 */
	TuYou.prototype.pagingQuery = function(triggerButtonId, url){
		
		var $nextPage = $('#' + triggerButtonId);
		if(typeof(start_paging) == 'undefined'){
			
			start_paging = 0;
		}
		$.post(url, {pn : start_paging}, function(text){
			
			$nextPage.parent().before(text);
			start_paging += pageSize;
				
		}, 'html');
	};
	
	/**
	 * 得到一个光标位置，在一个input中
	 */
	TuYou.prototype.getCursortPosition = function(ctrl) {
	    var CaretPos = 0;   
	    if (document.selection) { // IE Support
	    	
	    	ctrl.focus ();
	        var Sel = document.selection.createRange ();
	        Sel.moveStart ('character', -ctrl.value.length);
	        CaretPos = Sel.text.length;
	    } else if (ctrl.selectionStart || ctrl.selectionStart == '0'){ // Firefox support
	    	
	    	CaretPos = ctrl.selectionStart;
	    }
	    return (CaretPos);
	};
	
	/**
	 * 设置光标的位置
	 */
	TuYou.prototype.setCaretPosition = function(ctrl, pos){
	    if(ctrl.setSelectionRange)
	    {
	        ctrl.focus();
	        ctrl.setSelectionRange(pos,pos);
	    }
	    else if (ctrl.createTextRange) {
	        var range = ctrl.createTextRange();
	        range.collapse(true);
	        range.moveEnd('character', pos);
	        range.moveStart('character', pos);
	        range.select();
	    }
	};
	
	/**
	 * 判断是否在微信浏览器中
	 */
	TuYou.prototype.isWeiXin = function(){ 
		var ua = window.navigator.userAgent.toLowerCase();
		if(typeof(ua.match(/MicroMessenger/i)) != 'undefined' && ua.match(/MicroMessenger/i) != null){ 
			
			return true; 
		}else{
			
			return false; 
		} 
	};
	
	/**
	 * 判断一个对象是否为空，包括空白字符串和没有元素的数组
	 */
	TuYou.prototype.isNull = function(obj){
		
		if(typeof(obj) == 'undefined' || obj == null){
			
			return true;
		}else if(typeof(obj) == 'string' && $.trim(obj) == ''){
			
			return true;
		}else if(obj instanceof Array && obj.length == 0){
			
			return true;
		}
		return false;
	};
	
	/**
	 * 显示下拉列表
	 */
	TuYou.prototype.TreeCombox = function(dom){
				
		var $dom = $(dom);
		if(this.isNull($dom.attr('_id'))){
			
			var tree = null;
			var setting = {
					async: {
						enable: true,
						url:$dom.attr('url'),
						autoParam:["id"],
						otherParam:{"operationFlag":"1"},
						dataFilter:function(treeId, parentNode, responseData){
							
							if(responseData && responseData.length > 0){
								
								if(responseData[0].pId=="-1"){
									
									var root = tree.addNodes(null, {id:"-1", name:"顶层节点", isParent:true, open:true});
								}
								var parent = tree.getNodeByParam("id", responseData[0].pId);
								tree.addNodes(parent, responseData);
							}
							return null;
						}
					},
					data: {
						simpleData: {
							idKey: "id",
							pIdKey: "pId"
						}
					},
					callback: {
						
						onDblClick : function(event, treeId, treeNode){
							
							var $option = $dom.find('option');
							$option.val(treeNode.id);
							$option.text(treeNode.name);
							ul.fadeOut("fast");
						}
					}
			};
			
			var id = "id_" + Math.floor(Math.random() * 100000);
			$dom.attr('_id', id);
			var ul = $('<ul id="' + id + '" class="ztree" style="margin-top:0; position:absolute; border:solid 1px orange; min-height:200px; display:none; background:white;" />');
			ul.css({left: $dom.offset().left + "px", top: $dom.offset().top + $dom.outerHeight() + "px", width : $dom.outerWidth()});
			$("body").append(ul);
			tree = $.fn.zTree.init(ul, setting);
		}
		var ul = $("#" + $dom.attr('_id'));
		ul.slideDown("fast");
	}
	
	/** 自定义空指针异常 * */
	var NullPointerException = function(message) {
		alert(message);
	};
	
	/** ***********************************基础类*************************************** */
	
	/**
	 * 根据指定的格式获取当前的日期字符串
	 * 
	 * @param value
	 *            指定的日期格式
	 * @result 返回指定的日期格式, 如果没有指定,则返回默认的日期格式
	 */
	TuYou.prototype.getDateString = function(format) {
		try {
			var date = new Date();
			var year = date.getFullYear();
			var month = date.getMonth();
			var day = date.getDate();
			var hour = date.getHours();
			var minute = date.getMinutes();
			var second = date.getSeconds();
	
			if (hour < 10) {
				hour = "0" + hour;
			}
			if (minute < 10) {
				minute = "0" + minute;
			}
			if (second < 10) {
				second = "0" + second;
			}
			month = month + 1;	
			if (month < 10) {
				month = "0" + month;
			}
			if (day < 10) {
				day = "0" + day;
			}
	
			if (this.isNull(format)) {
				return year + "-" + month + "-" + day;
			} else if('yyyy年MM月dd日' == format) {
				var temp = year + "年" + month + "月" + day + "日";
				var d = new Array("星期日","星期一","星期二","星期三","星期四","星期五","星期六");
				var dd = d[date.getDay()];
				return temp + " " + dd;
			} else {
				if ("yyyy-MM-dd" == format) {
					return year + "-" + month + "-" + day;
				} else if ("yyyy年MM月dd日" == format) {
					return year + "年" + month + "月" + day + "日";
				} else if ("yyyy-MM-dd hh:mm:ss" == format) {
					return year + "-" + month + "-" + day + " " + hour + ":"
							+ minute + ":" + second;
				} else if ("yyyy年MM月dd日 hh时mm分ss秒" == format) {
					return year + "年" + month + "月" + day + "日  " + hour
							+ "时" + minute + "分" + second + "秒";
				}
			}
		} catch (e) {
			return "";
		}
	};
	
	/**
	 * 去除指定字符串前后的空格
	 * 
	 * @param value
	 *            要去除空格的字符串
	 * @result 返回去除空格后的字符串
	 */
	TuYou.prototype.trim = function(value) {
		try {
			var re = /\s/g;
			value = value.replace(re, "");
			return value;
		} catch (e) {
			return value;
		}
	};
	
	/**
	 * 返回当前浏览器的类型
	 */
	TuYou.prototype.browserVersion = function() {
		try {
			if ($.browser.msie) {
				return "IE";
			} else if ($.browser.mozilla) {
				return "Mozilla FireFox";
			} else if ($.browser.safari) {
				return "Safari";
			} else if ($.browser.opera) {
				return "Opera";
			} else {
				return "unknow";
			}
		} catch (e) {
			return "unknow";
		}
	};
	
	/**
	 * 获取指定字符串的长度
	 * 
	 * @param value
	 *            指定的字符串
	 * @param ignoreWhiteSpace
	 *            是否忽略字符串前后的空格 ture为忽略 false不忽略
	 * @result 返回指定的字符串的长度
	 */
	TuYou.prototype.getLength = function(value, ignoreWhiteSpace) {
		try {
			var sum = 0;
	/** 返回的字符串长度 */
	
			if (ignoreWhiteSpace) {
				value = this.trim(value);
			}
			for (var i = 0; i < value.length; i++) {
				if ((value.charCodeAt(i) >= 0) && (value.charCodeAt(i) <= 255)) {
					sum = sum + 1;
				} else {
					sum = sum + 2;
				}
			}
			return sum;
		} catch (e) {
			return 0;
		}
	};
	
	/**
	 * 根据指定的url打开一个页面
	 * 
	 * @param url
	 *            要打开的页面地址
	 */
	TuYou.prototype.goPage = function(url) {
		try {
			if (!this.isNull(url)) {
				window.location.href = url;
			}
		} catch (e) {
		}
	};
	
	/** ***********************************验证类*************************************** */
	
	/**
	 * 验证指定的字符串是否为email格式的
	 * 
	 * @param email
	 *            要验证的字符串
	 * @result 如果验证合法则返回true, 否则返回false
	 */
	TuYou.prototype.isEmail = function(email) {
		try {
			var myReg = /^[-_A-Za-z0-9]+@([_A-Za-z0-9]+\.)+[A-Za-z0-9]{2,3}$/;
			if (myReg.test(email)) {
				return true;
			} else {
				return false;
			}
		} catch (e) {
			return false;
		}
	};
	
	/**
	 * 判断指定字符串是否为为合法的IP地址
	 * 
	 * @param value
	 *            要判断的字符串
	 * @result 如果是IP则返回true, 否则返回false
	 */
	TuYou.prototype.isIP = function(value) {
		try {
			if (this.isNull(value)) {
				return false;
			}
			var re = /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/g;
			if (re.test(value)) {
				if (RegExp.jQuery1 < 256 && RegExp.jQuery2 < 256 && RegExp.jQuery3 < 256
						&& RegExp.jQuery4 < 256) {
					return true;
				}
			}
			return false;
		} catch (e) {
			return false;
		}
	};
	
	/**
	 * 判断指定字符串是否为int类型
	 * 
	 * @param value
	 *            要判断的字符串
	 * @result 如果是整数类型则返回true, 否则返回false
	 */
	TuYou.prototype.isInteger = function(value) {
		try {
			var regu = /^[-]{0,1}[0-9]{1,}$/;
			return regu.test(value);
		} catch (e) {
			return false;
		}
	};
	
	/**
	 * 判断指定字符串是否为手机号码
	 * 
	 * @param value
	 *            要判断的字符串
	 * @result 如果是则返回true, 否则返回false
	 */
	TuYou.prototype.isMobile = function(value) {
		try {
			var regu = /^([1][3]|[1][5])[0-9]{9}$/;
			var re = new RegExp(regu);
			if (re.test(value)) {
				return true;
			} else {
				return false;
			}
		} catch (e) {
			return false;
		}
	};
	
	/**
	 * 判断指定字符串是否为电话号码,小灵通,手机号码
	 * 
	 * @param value
	 *            要判断的字符串
	 * @result 如果是则返回true, 否则返回false
	 */
	TuYou.prototype.isPhone = function(value) {
		try {
			if (this.isNull(value)) {
				return false;
			}
			var isSuc = false;
			var reg = /^(\({0,1}\d{3,4})\){0,1}(-){0,1}(\d{7,8})$/;
			if(reg.test(value)) {
				isSuc = true;
			} else {
				reg = /^1[3,5]\d{9}$/;
				if(reg.test(value)) {
					isSuc = true;
				}
			}
			return isSuc;
		} catch (e) {
			return false;
		}
	};
	
	/**
	 * 判断指定字符串是否为金额格式
	 * 
	 * @param value
	 *            要判断的字符串
	 * @result 如果是则返回true, 否则返回false
	 */
	TuYou.prototype.isMoney = function(value) {
		try {
			var regu = "^[0-9]+[\.][0-9]{0,6}$";
			var re = new RegExp(regu);
			if (re.test(value)) {
				return true;
			}
			return false;
		} catch (e) {
			return false;
		}
	};
	
	/**
	 * 判断指定字符串是否为浮点数类型
	 * 
	 * @param value
	 *            要判断的字符串
	 * @result 如果是则返回true, 否则返回false
	 */
	TuYou.prototype.isFloat = function(value) {
		try {
			var regu = "^[0-9]+[\.][0-9]{0,2}$";
			var re = new RegExp(regu);
			if (re.test(value)) {
				return true;
			}
			return false;
		} catch (e) {
			return false;
		}
	};
	
	/**
	 * 判断指定字符串是否为数字
	 * 
	 * @param value
	 *            要判断的字符串
	 * @result 如果是则返回true, 否则返回false
	 */
	TuYou.prototype.isNumber = function(value) {
		try {
			var regu = /[0-9]$/;
			var re = new RegExp(regu);
			if (re.test(value)) {
				return true;
			}
			return false;
		} catch (e) {
			return false;
		}
	};
	
	/**
	 * 判断指定字符串是否为指定的长度
	 * 
	 * @param value
	 *            要判断的字符串
	 * @result 如果是则返回true, 否则返回false
	 */
	TuYou.prototype.checkLength = function(value, minLength, maxLength) {
		try {
			if (this.isNull(value) || this.isNull(minLength)
					|| this.isNull(maxLength)) {
				return false;
			} else if (value.length < minLength || value.length > maxLength) {
				return false;
			} else {
				return true;
			}
		} catch (e) {
			return false;
		}
	};
	
	/**
	 * 判断指定字符串是否为身份证号码
	 * 
	 * @param value
	 *            要判断的字符串
	 * @result 如果是则返回true, 否则返回false
	 */
	TuYou.prototype.isIdCard = function(value) {
		try {
			if (this.isNull(value)) {
				return false;
			}
			value = this.trim(value);
			if (this.getLength(value) == 15 || this.getLength(value) == 18) {
				return true;
			} else {
				return false;
			}
		} catch (e) {
			return false;
		}
	};
	
	/** ***********************************表单类*************************************** */
	/**
	 * {1} 文本框只能输入数字代码(小数点也不能输入): onkeyup="this.value=this.value.replace(/\D/g,'')" *
	 * {1} 文本框只能输入数字代码(小数点也不能输入):
	 * onafterpaste="this.value=this.value.replace(/\D/g,'')"
	 */
	
	/**
	 * 限制指定的objectElement只能输入数字
	 * 
	 * @param objectElement
	 *            要绑定的元素ID
	 * @result
	 */
	TuYou.prototype.OnlyInputNumber = function(objectElement) {
		try {
			var version = this.browserVersion();
			var element = document.getElementById(objectElement);
	
			if ("IE" == version) {
				element.attachEvent("onkeyup", function() {
							element.value = element.value.replace(/\D/g, '');
						});
				element.attachEvent("onafterpaste", function() {
							element.value = element.value.replace(/\D/g, '');
						});
			} else if ("Mozilla FireFox" == version) {
				element.addEventListener("keyup", function() {
							element.value = element.value.replace(/\D/g, '');
						}, false);
				element.addEventListener("afterpaste", function() {
							element.value = element.value.replace(/\D/g, '');
						}, false);
			} else {
				element.addEventListener("keyup", function() {
							element.value = element.value.replace(/\D/g, '');
						}, false);
				element.addEventListener("afterpaste", function() {
							element.value = element.value.replace(/\D/g, '');
						}, false);
			}
		} catch (e) {
			return false;
		}
	};
	
	/**
	 * 限制指定的objectElement只能输入数字和小数点
	 * 
	 * @param objectElement
	 *            要绑定的元素
	 * @result
	 */
	TuYou.prototype.OnlyInputNumberAndPoint = function(objectElement) {
		try {
			var version = this.browserVersion();
			var element = document.getElementById(objectElement);
	
			if ("IE" == version) {
				element.attachEvent("onkeyup", function() {
					// 先把非数字的都替换掉，除了数字和.
					element.value = element.value.replace(/[^\d.]/g, "");
						// 必须保证第一个为数字而不是.
						element.value = element.value.replace(/^\./g,"");
						// 保证只有出现一个.而没有多个.
						element.value = element.value.replace(/\.{2,}/g,".");
						// 保证.只出现一次，而不能出现两次以上
						element.value =
						element.value.replace(".","$#$").replace(/\./g,"").replace("$#$",".");
					});
				element.attachEvent("onafterpaste", function() {
					// 先把非数字的都替换掉，除了数字和.
					element.value = element.value.replace(/[^\d.]/g, "");
						// 必须保证第一个为数字而不是.
						 element.value = element.value.replace(/^\./g,"");
						// 保证只有出现一个.而没有多个.
						 element.value = element.value.replace(/\.{2,}/g,".");
						// 保证.只出现一次，而不能出现两次以上
						 element.value =
						 element.value.replace(".","$#$").replace(/\./g,"").replace("$#$",".");
					});
			} else if ("Mozilla FireFox" == version) {
				element.addEventListener("keyup", function() {
					// 先把非数字的都替换掉，除了数字和.
					element.value = element.value.replace(/[^\d.]/g, "");
						// 必须保证第一个为数字而不是.
						 element.value = element.value.replace(/^\./g,"");
						// 保证只有出现一个.而没有多个.
						 element.value = element.value.replace(/\.{2,}/g,".");
						// 保证.只出现一次，而不能出现两次以上
						 element.value =
						 element.value.replace(".","$#$").replace(/\./g,"").replace("$#$",".");
					}, false);
				element.addEventListener("afterpaste", function() {
					// 先把非数字的都替换掉，除了数字和.
					element.value = element.value.replace(/[^\d.]/g, "");
						// 必须保证第一个为数字而不是.
						 element.value = element.value.replace(/^\./g,"");
						// 保证只有出现一个.而没有多个.
						 element.value = element.value.replace(/\.{2,}/g,".");
						// 保证.只出现一次，而不能出现两次以上
						 element.value =
						 element.value.replace(".","$#$").replace(/\./g,"").replace("$#$",".");
					}, false);
			} else {
				// do something here if you'd like
			}
		} catch (e) {
			return false;
		}
	};
	
	/**
	 * 限制指定的objectElement只能输入字母和汉字
	 * 
	 * @param objectElement
	 *            要绑定的元素ID
	 * @result
	 */
	TuYou.prototype.OnlyInputLetterAndCharacter = function(objectElement) {
		try {
			var version = this.browserVersion();
			var element = document.getElementById(objectElement);
	
			if ("IE" == version) {
				element.attachEvent("onkeyup", function() {
							element.value = element.value.replace(/[\d]/g, '');
						});
				element.attachEvent("onbeforepaste", function() {
							clipboardData.setData('text', clipboardData
											.getData('text').replace(/[\d]/g, ''));
						});
			} else if ("Mozilla FireFox" == version) {
				element.addEventListener("keyup", function() {
							element.value = element.value.replace(/[\d]/g, '');
						}, false);
				element.addEventListener("onbeforepaste", function() {
							clipboardData.setData('text', clipboardData
											.getData('text').replace(/[\d]/g, ''));
						}, false);
			} else {
				// do something here if you'd like
			}
		} catch (e) {
			return false;
		}
	};
	
	/**
	 * 限制指定的objectElement只能输入字母和汉字
	 * 
	 * @param objectElement
	 *            要绑定的元素ID
	 * @result
	 */
	TuYou.prototype.OnlyInputLetterAndNumber = function(objectElement) {
		try {
			var version = this.browserVersion();
			var element = document.getElementById(objectElement);
	
			if ("IE" == version) {
				element.attachEvent("onkeyup", function() {
							element.value = element.value
									.replace(/[^\w\.\@\/]/ig, '');
						});
			} else if ("Mozilla FireFox" == version) {
				element.addEventListener("keyup", function() {
							element.value = element.value
									.replace(/[^\w\.\@\/]/ig, '');
						}, false);
			} else {
				// do something here if you'd like
			}
		} catch (e) {
			return false;
		}
	};
	
	/**
	 * 限制指定的objectElement只能输入数字和英文
	 * 
	 * @param objectElement
	 *            要绑定的元素ID
	 * @result
	 */
	TuYou.prototype.OnlyInputNumberAndEnglish = function(objectElement) {
		try {
			var version = this.browserVersion();
			var element = document.getElementById(objectElement);
	
			if ("IE" == version) {
				element.attachEvent("onkeyup", function() {
							element.value = element.value
									.replace(/[^\d|chun]/g, '');
						});
			} else if ("Mozilla FireFox" == version) {
				element.addEventListener("keyup", function() {
							element.value = element.value
									.replace(/[^\d|chun]/g, '');
						}, false);
			} else {
				// do something here if you'd like
			}
		} catch (e) {
			return false;
		}
	};
	
	/**
	 * 限制指定的objectElement只能输入中文
	 * 
	 * @param objectElement
	 *            要绑定的元素ID
	 * @result
	 */
	TuYou.prototype.OnlyInputCharacter = function(objectElement) {
		try {
			var version = this.browserVersion();
			var element = document.getElementById(objectElement);
	
			if ("IE" == version) {
				element.attachEvent("onkeyup", function() {
							element.value = element.value.replace(
									/[^\u4E00-\u9FA5]/g, '');
						});
				element.attachEvent("onbeforepaste", function() {
							clipboardData.setData('text', clipboardData
											.getData('text').replace(
													/[^\u4E00-\u9FA5]/g, ''));
						});
			} else if ("Mozilla FireFox" == version) {
				element.addEventListener("keyup", function() {
							element.value = element.value.replace(
									/[^\u4E00-\u9FA5]/g, '');
						}, false);
				element.addEventListener("onbeforepaste", function() {
							clipboardData.setData('text', clipboardData
											.getData('text').replace(
													/[^\u4E00-\u9FA5]/g, ''));
						}, false);
			} else {
				// do something here if you'd like
			}
		} catch (e) {
			return false;
		}
	};
	
	/** ******************************************操作JSON*********************************** */
	
	/**
	 * 根据指定的字符串(符合json规范的)创建JSON字符串
	 * 
	 * @param value
	 *            指定的符合json规范的字符串
	 * @result 返回JSON对象的字符串
	 */
	TuYou.prototype.createJson = function(value) {
		try {
			if (this.isNull(value)) {
				return new NullPointerException("the value is null");
			}
			var jsonObject = JSON.parse(value);
			if (!this.isNull(jsonObject)) {
				return jsonObject;
			}
		} catch (e) {
		}
	};
	
	/**
	 * 根据指定的JSON对象反转为JS字符串
	 * 
	 * @param value
	 *            JSON对象
	 * @result 返回JS语法的字符串
	 */
	TuYou.prototype.reverceJson = function(value) {
		try {
			if (this.isNull(value)) {
				return new NullPointerException("the value is null");
			}
			var tempValue = JSON.stringify(value);
			if (!this.isNull(tempValue)) {
				return tempValue;
			}
		} catch (e) {
		}
	};
	
	
	TuYou.prototype.encode = function(value) {
		try {
			return encodeURI(encodeURI(value));
		}catch(e){}
	};
	
	/**
	 * RGB颜色对象转为16进制
	 */
	TuYou.prototype.RgbToHex = function(rgb) {
		try {
			if (rgb.charAt(0) == '#') {
				return rgb;
			}
			var ds = rgb.split(/\D+/);
			var decimal = Number(ds[1]) * 65536 + Number(ds[2]) * 256 + Number(ds[3]);
			
			//转为16进制
			var s = decimal.toString(16);
			while (s.length < 6) {
				s = "0" + s;
			}
			
			return "#" + s;
		}catch(e){}
	};
	
	/**
	 * 拷贝源内容到目标元素的内容
	 */
	TuYou.prototype.copyContent = function(source, target) {
		try {
			if(tuyou.isNull(source) || tuyou.isNull(target)) {
				return false;
			}
			
			var s1 = $("#"+source);
			var s2 = $("#"+target);
			
			s2.val(s1.val());
			return false;
		}catch(e) {
		}
	};
	 
	 /**
	  * 添加收藏
	  */
	 TuYou.prototype.addFavorite = function(sURL, sTitle) {
	 	try {
	      window.external.addFavorite(sURL, sTitle);
	    } catch (e) {
	      try {
	          window.sidebar.addPanel(sTitle, sURL, "");
	      } catch (e) {
	          alert("加入收藏失败，请使用Ctrl+D进行添加");
	      }
	    }
	 };
	 
	 /**
	  * 设为首页
	  */
	 TuYou.prototype.setHome = function(obj,vrl) {
	 	try {
	      obj.style.behavior='url(#default#homepage)';obj.setHomePage(vrl);
	    } catch(e){
	      if(window.netscape) {
	        try {
	          netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
	        } catch (e) {
	          alert("此操作被浏览器拒绝！\n请在浏览器地址栏输入“about:config”并回车\n然后将 [signed.applets.codebase_principal_support]的值设置为'true',双击即可。");
	        }
	        var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
	        prefs.setCharPref('browser.startup.homepage',vrl);
	       }
	    }
	    //<a onclick="AddFavorite(window.location,document.title)">加入收藏</a>
		//<a onclick="SetHome(this,window.location)">设为首页</a>
	 };
	   /**
	    * 选中checkbox中的checked
	    * @param selectId 目标的select
	    * @param value 目标value
	    */
	   TuYou.prototype.selectCheckBoxValue = function(selectId, value) {
	   		try {
				var chkboxs = $("input[name="+selectId+"]");
				var array = new Array(); 
				array = value.split(',');
				for(var i=0; i<array.length; i++) {
					var t1 = tuyou.trim(array[i]);
					for(var j=0; j<chkboxs.size(); j++) {
						var t2 = tuyou.trim($(chkboxs.get(j)).val());
						if (t1 == t2){
							$(chkboxs.get(j)).attr("checked", "true");
							break;
						}
					}
				}
			}catch(e) {
			}
	   };
	   
	   /**
		 * 选中单选按钮
		 * @param radioName 单选按钮组的名称
		 * @param value 目标value
		 */
	   TuYou.prototype.selectRadioValue = function(radioName, value) {
	   		try {
				if(radioName != null && value != null && value != "" && radioName != "") {
					var temp = document.getElementsByName(radioName);
					for(var i=0; i<temp.length; i++) {
						if(value == temp[i].value) {
							temp[i].checked = true;
							break;
						}
					}
				}
			}catch(e) {
			}
	   };
	   
	   /**
		 * 选中单选按钮
		 * @param radioName 单选按钮组的名称
		 * @param value 目标value
		 */
	   TuYou.prototype.selectRadio = function(radioName) {
	   		try {
				if(radioName != null && radioName != "" && radioName != undefined) {
					var currentValue = $($("input[name="+radioName+"]").get(0)).attr("currentValue");
					this.selectRadioValue(radioName, currentValue);
				}
			}catch(e) {
			}
	   };
	   
	    /**
	    * 选中select中的option
	    * @param selectId 目标的select
	    * @param value 目标value
	    */
	   TuYou.prototype.selectSelect = function(selectId) {
	   		try {
				var temp = $("#"+selectId);
				var currentValue = temp.attr("currentValue");
				this.selectValue(selectId, currentValue);
			}catch(e) {
			}
	   };
	   
	   /**
		 * 选中select中的option
		 * @param selectId 目标的select
		 * @param value 目标value
		 */
	   TuYou.prototype.selectMultiValue = function(selectId, value) {
	   		try {
				var array = new Array(); 
				array = value.split(',');
				
				var temp = $("#"+selectId)[0];
				for(var i=0; i<array.length; i++) {
					var t = array[i];
					for(var j=0; j<temp.length; j++) {
						var tt = parseInt(temp.options[j].value);
						if (tt == t){
							temp.options[j].selected = true;
							break;
						}
					}
					t = null;
				}
			}catch(e) {
			}
	   };
	   
	   /**
		 * 选中所有的复选框
		 * @param ids 复选框的name属性
		 * @param type 按钮类型
		 */
	   TuYou.prototype.checkAll = function(ids, id) {
	   		try {
				var t = $("#" +id);
				if(t.is(":checked")) {
					$("[name="+ids+"]:checkbox").attr("checked", "true"); 
				} else {
					$("[name="+ids+"]:checkbox").removeAttr("checked");
				}
				return false;
			}catch(e) {
			}
	   };
	   
	   /**
	    * 获取当前页面的URL
	    */
	   TuYou.prototype.currentUrl = function(){
	   		return document.URL;
	   };
	   /**
	    * 获取上一页的URL
	    */
	   TuYou.prototype.prevUrl = function(){
	   		return document.referrer;
	   };
	   
	   /**
	    * 比较两个密码是否一致
	    * 一致返回true, 不一致返回false
	    * @param element1 元素ID
	    * @param element2 元素ID
	    */
	   TuYou.prototype.equalPassword = function(element1, element2) {
	   		try {
	   			var e1 = $("#"+element1);
	   			var e2 = $("#"+element2);
	   			if(e1.val() == e2.val()) {
	   				return true;
	   			}
	   			return false;
	   		}catch(e){
	   			return false;
	   		}
	   };
	   
	   /**
	    * 兼容IE和火狐和谷歌的复制链接方法 
	    */
	   TuYou.prototype.copy = function(meintext) {
	   		try {
	   			if (window.clipboardData) {
					window.clipboardData.setData("Text", meintext);
				 } else {
				 	var flashcopier = 'flashcopier';
				 	if(!document.getElementById(flashcopier)) {
				        var divholder = document.createElement('div');
				  		divholder.id = flashcopier;
				  		document.body.appendChild(divholder);
				 	}
				 	document.getElementById(flashcopier).innerHTML = '';
					var divinfo = '<embed src="/jslib/clipboard.swf" FlashVars="clipboard='+encodeURIComponent(meintext)+'" width="0" height="0" type="application/x-shockwave-flash"></embed>';
					document.getElementById(flashcopier).innerHTML = divinfo;
				}
				alert('地址已经复制到您的剪贴板，您可以发送给您的朋友啦！');
				return false;
	   		}catch(e){
	   			alert(e);
	   			return false;
	   		}
	   };
		
	   /**
	    * 处理没有的图片，或者丢失的图片
	    * @param defaultSrc 默认图片
	    * @return
	    */
	   TuYou.prototype.processNothingImg = function processNothingImg(defaultSrc) {
		   try{
				$("img").bind("error", function() {
			   		$(this).attr("src", defaultSrc);
			   	});
			   	var imgs = $("img");
			   	imgs.each(function(){
			   		var src = $(this).attr("src");
			   		if(src == "") {
			   			$(this).attr("src", defaultSrc);
			   		} else {
			   			if(document.all) {
			   				$(this).attr("src", src);
			   			}
			   		}
			   	});
		   }catch(e){
	   			alert(e);
	   			return false;
	   	   }
	   };
	   
	   /**
	    * 清空表单元素里面的值
	    */
	   TuYou.prototype.executeMethod = function(methodName) {
	   	  try {
	   	  	eval(methodName+"()");
	   	  } catch(e){
	   	  	return false;
	   	  }
	   };
	   
	   /**
	    * 返回上一页
	    */
	   TuYou.prototype.back = function(stepNum){
	   	  if(stepNum == null || stepNum == ''){
	   	  	window.history.go(-1);
	   	  } else {
	   	  	window.history.go(stepNum);
	   	  }
	   };
	   
	   /**
	    *  转向到某个url
	    */
	   TuYou.prototype.goUrl = function(url){
	   	  window.location.href = url;
	   };
	   
	   /**
	    *  刷新当前页面
	    */
	   TuYou.prototype.reload = function(){
	   	  window.location.reload();
	   };
	   
	   /**
	    * 根据表单的ID或者NAME获取元素
	    */
	   TuYou.prototype.getFormObject = function(elementId) {
	   	   var obj = $("#" + elementId);
	   	   if(obj.attr("tagName") == undefined) {
	   	   	   obj = $("input[name="+elementId+"]:checked");
	   	   }
	   	   return obj;
	   };
	   
	   /**
	    * 弹出alert
	    */
	   TuYou.prototype.alert = function(value, time, callback) {
		   bootbox.hideAll();
		   var dialog = bootbox.alert({
			   title : '<span class="label label-lg label-primary arrowed-right">提示</span>',
			   message : '<h3>' + value + '</h3>'
			   });
		   if(!this.isNull(time)) {
			   
			   setTimeout(function(){
				   
				   dialog.modal('hide');
				   if(callback){
					   
					   callback();
				   }
			   }, time);
		   }
	   };
	   
	   /**
	    * 弹出加在提示
	    * @param msg
	    * @returns
	    */
	   TuYou.prototype.loading = function(msg){
		   
		   //显示上传提示
		   var loading = bootbox.dialog({
			   size: 'small',
			   animate : false,
			   closeButton : false,
			   message : '<h2 style="background:url(/library/layer-3.0.1/skin/default/loading-1.gif) no-repeat; padding-left: 30px;">'+msg+'</h2>',
			   buttons:[]
		   });
		   return loading;
	   };
	   
	   /**
	    * 确认弹出框
	    * @param msg
	    * @returns
	    */
	   TuYou.prototype.confirm = function(msg, okCallcack, cancelCallback){
		   
		   //显示上传提示
		   var confirm = bootbox.confirm({
			   title : '<span class="label label-xlg label-warning arrowed-right"">提示</span>',
			   size: 'small',
			   message : '<h3>' + msg + '</h3>',
			   callback : function(result){
				   
				   if(result == true && okCallcack){ //点击yes才执行回调函数
					   
					   okCallcack();
				   }else if(result == false && cancelCallback){
					   
					   cancelCallback();
				   }
			   }
		   });
		   return confirm;
	   };
	   
	   /**
	    * 输入确认弹出框
	    * @param msg
	    * @returns
	    */
	   TuYou.prototype.prompt = function(msg, okCallcack, cancelCallback){
		   
		   //显示上传提示
		   var prompt = bootbox.prompt({
			   title : '<span class="label label-xlg label-success arrowed-right">' + msg + '</span>',
			   size: 'small',
			   callback : function(result){
				   
				   if(okCallcack){ //点击yes才执行回调函数
					   
					   okCallcack(result);
				   }
			   }
		   });
		   return prompt;
	   };
	   
	   /**
	    * 倒计时跳转到制定页面
	    */
	   TuYou.prototype.countDown = function(cls, url){
			
		   countDownInner();
		   function countDownInner(){
				
				var number = parseInt($('#' + cls).text());
				if(typeof number == 'number' && !isNaN(number)){
					
					if (number > 0) {
						
						--number;
						$('#' + cls).text(number);
						setTimeout(countDownInner, 1000);
					} else {
						
						tuyou.goUrl(url);
					}
				}
		   }
	   };
	   
	   /**
	    * 首字母小写
	    */
	   TuYou.prototype.firstCharacterToLowerCase = function(value) {
		   var v1 = value.substring(0, 1);
		   var v2 = value.substr(1);
		   v1 = v1.toLowerCase();
		   return v1 + v2;
	   };
	   
	   /**
	    * dom1滚动到dom2的高度，动画效果持续一秒
	    * @param dom1 
	    * @param dom2
	    */
	   TuYou.prototype.scrollTo = function(dom1, dom2, height, time) { 
		   
		   var offset = $(dom2).offset(); //得到pos这个div层的offset，包含两个值，top和left 
		   var top = offset.top - (height ? height : 0);
		   $(dom1).animate({ 
			   scrollTop : top //让body的scrollTop等于pos的top，就实现了滚动 
		   	},(time ? time : 1000)); 
	   };
	   
	   /**
	    * dom1滚动到dom2的高度，动画效果持续一秒
	    * @param dom2
	    */
	   TuYou.prototype.scrollWindow = function(dom2, height) { 
		   
		   var offset = $(dom2).offset(); //得到pos这个div层的offset，包含两个值，top和left 
		   var top = offset.top - (height ? height : 0);
		   $(window).animate({ 
			   scrollTop : top //让body的scrollTop等于pos的top，就实现了滚动 
		   },1000);
	   };
	
	   window.tuyou = new TuYou();
})();